<?php if (!defined('CORE_DIR')) die('Wrong entry point!');

/* 
 * Copyright 2010 Anton Muraviev a.k.a kuromaisu
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */
?>
<!DOCTYPE HTML>
<html>
<head>
	<title><?= $test_name ?></title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?= Aero::run('libs/specification/report_stylesheet') ?>
</head>
<body>
	<h1><?= $test_name ?></h1>
	<ul class="summary">
		<li<?= $behaviors_total > 0 ? ' class="total"' : '' ?>><em><?= number_format($behaviors_total) ?></em> behavior<?= $behaviors_total > 1 ? 's' : '' ?></li>
		<li<?= $behaviors_failed > 0 ? ' class="failed"' : '' ?>><em><?= number_format($behaviors_failed) ?></em> failed</li>
		<li<?= $behaviors_skipped > 0 ? ' class="skipped"' : '' ?>><em><?= number_format($behaviors_skipped) ?></em> skipped</li>
	</ul>
<?php $total_exc = count($exceptions); $i = 0; $showed_next = false; ?>
<?php foreach ($exceptions as $spec): $i++; ?>
	<div class="specification">
<?php 	if (isset($spec['exception'])): ?>
	<?= Aero::run('libs/specification/report_item',array(
		'item' => $spec,
	)) ?>
<?php 	else: ?>
	<h2<?= count($spec['failed']) > 0 ? ' class="failed"' : '' ?>>
		<span><?= $spec['specification'] ?></span>
<?php 		if (count($spec['failed']) > 0): ?>
		<small><?= count($spec['failed']) . ' behavior'.(count($spec['failed']) > 1 ? 's' : '').' failed' ?></small>
<?php 		endif ?>
<?php 		if (count($spec['skipped']) > 0): ?>
		<small><?= count($spec['skipped']) . ' behavior'.(count($spec['skipped']) > 1 ? 's' : '').' skipped' ?></small>
<?php 		endif ?>
		<a id="spec-num-<?= $i ?>" class="prev-spec<?= ($i > 1 && $showed_next) ? '' : ' hidden' ?>" href="#spec-num-<?= $i - 1 ?>">prev</a>
<?php 		if ($i < $total_exc && (count($spec['failed'])*3 + count($spec['skipped'])) > 4): $showed_next = true; ?>
		<a class="next-spec" href="#spec-num-<?= $i + 1 ?>">next</a>
<?php 		else: $showed_next = false; ?>
<?php 		endif ?>
	</h2>
	
<?php 		foreach ($spec['failed'] as $behavior): ?>
	<?= Aero::run('libs/specification/report_item',array(
		'parent' => $spec,
		'item' => $behavior
	)) ?>
<?php 		endforeach ?>
<?php 		foreach ($spec['skipped'] as $behavior): ?>
	<?= Aero::run('libs/specification/report_item',array(
		'parent' => $spec,
		'item' => $behavior
	)) ?>
<?php 		endforeach ?>
<?php 	endif ?>
	</div>
<?php endforeach ?>
</body>
</html>